import s from './ArtifactPower.module.css'
import {Button, Input, MessagePlugin} from "tdesign-react";
import {useState} from "react";

const ArtifactPower = () => {

    const [role, setRole] = useState("")

    const updateCallback = (results) => {
        console.log(results)
        if (results.status === "ok") {
            MessagePlugin.success("神器能量写入成功！需重载游戏（过图读条即可）生效").then()
        } else {
            MessagePlugin.error("神器能量写入失败！请检查数据库是否启动").then()
        }
    }

    const submit = () => {
        window?.electronAPI?.updateArtifactPower(role, updateCallback)
    }

    return (
        <div className={s.container}>
            <div className={s.actionBar}>
                <Input
                    onChange={setRole}
                    value={role}
                    style={{width: 300}}
                    placeholder={"输入角色名称"}
                />
                <Button onClick={submit}>注入万兆神器能量</Button>
            </div>

        </div>
    )
}
export default ArtifactPower